package ch.inputRoute;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;

public class InputRouteActivity extends Activity {
	public static final String ROOM_PARAMETER = "room";

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
				R.layout.list_item, ROOMS);
		final AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView);

		textView.setAdapter(adapter);

		Button next = (Button) findViewById(R.id.buttonFind);
		next.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent myIntent = new Intent(v.getContext(), MapsActivity.class);
				myIntent.putExtra(ROOM_PARAMETER, textView.getText().toString());
				startActivityForResult(myIntent, 0);
			}
		});

		Button plan = (Button) findViewById(R.id.buttonShowPlan);

		plan.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent myIntent = new Intent(v.getContext(), PlanActivity.class);
				startActivityForResult(myIntent, 0);
			}
		});

		Button loadDb = (Button) findViewById(R.id.buttonLoadPosFromDb);
		loadDb.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent myIntent = new Intent(v.getContext(),
						LoadFromDbActivity.class);
				startActivityForResult(myIntent, 0);

			}
		});
	}

	private static final String[] ROOMS = new String[] { "B202", "F211",
			"F320", "B200", "E407", "F535", "F311", "P11", "P23", "E233",
			"C123", "C111", "C122", "F310", "B123", "B112" };

}